﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using eTMS.Controllers.HocKyService;
using eTMS.Controllers;
using eTMS.Commons;
namespace eTMS.Controls{
   public class ComboBoxHocKy : ComboBoxBindingBase<HocKyEntity>
   {
		public ComboBoxHocKy(){
            this.DropDownStyle = ComboBoxStyle.DropDownList;
	    }
		//Bind data to txtHocKy
        public override void BindData(){
            this.DropDownStyle = ComboBoxStyle.DropDownList;
		    List<HocKyEntity>lsHocKy = new List<HocKyEntity>(HocKyController.ListHocKyStatic.ToArray());
			lsHocKy=FilterList(lsHocKy);
		    if(IsAddChooseItem){
				HocKyEntity eChooseItem = new HocKyEntity();
				eChooseItem.TenHocKy = Constants.CHOOSE_ITEM;
				lsHocKy.Insert(0,eChooseItem);
			}		
		    if(IsAddAllItem){
				HocKyEntity eChooseItem = new HocKyEntity();
                eChooseItem.TenHocKy = Constants.APP_ALL;
				lsHocKy.Insert(0,eChooseItem);
			}
            this.DisplayMember = "TenHocKy";
		    object currentSelected=this.SelectedValue;
		    this.ValueMember = "HocKy_ID";
		    this.DataSource = lsHocKy;
		    if(currentSelected==null){
				if(this.Items.Count>0){
					this.SelectedIndex=0;
				}
            }
            else{
					this.SelectedValue = currentSelected;
					if(this.SelectedValue==null){
						if(this.Items.Count>0){
						this.SelectedIndex=0;
					}
                }
            }
        }
	}
}
